package org.abc.fund.controller.strategy.response;

import java.math.BigDecimal;
import java.time.LocalDate;
import lombok.Builder;
import lombok.Data;
import org.abc.fund.entity.strategy.Backtest;

@Data
@Builder
public class BacktestResponse {
  private Long id;
  private Long strategyId;
  private LocalDate startDate;
  private LocalDate endDate;
  private BigDecimal initialBalance;
  private String result;

  public static BacktestResponse fromEntity(Backtest backtest) {
    if (backtest == null) return null;
    return BacktestResponse.builder()
        .id(backtest.getId())
        .strategyId(backtest.getStrategy() != null ? backtest.getStrategy().getId() : null)
        .startDate(backtest.getStartDate())
        .endDate(backtest.getEndDate())
        .initialBalance(backtest.getInitialBalance())
        .result(backtest.getResult())
        .build();
  }
}
